////////////////////////////////////////////////
// File: News.java
// Description: Enter summary here after generation.
// Date: 2016-09-23 09:09:33
// Web: http://www.elanzhou.com/
////////////////////////////////////////////////
package com.mvc.entity;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;

import org.htmlparser.Node;
import org.htmlparser.Parser;
import org.htmlparser.tags.TableTag;

import java.util.Date;
import java.text.ParseException;
import java.text.SimpleDateFormat;
/**
 * news entity. @author 马威
 */
@Entity
@Table(name = "news")
public class News implements java.io.Serializable {

	private static final long serialVersionUID = 1L;
	@Id
	@Basic(optional = false)
	@GeneratedValue(strategy = GenerationType.IDENTITY)   
    @Column(name = "ID", nullable = false)
	private Integer ID;
    //标题
    @Column(name = "title")
	private  String Title;
    //栏目
    @Column(name = "syschannel")
	private  String Syschannel;
    //所属品类
    @Column(name = "fname")
	private  String Fname;
    //所属品种
    @Column(name = "catename")
	private  String Catename;
    //图片
    @Column(name = "newspic")
   	private  String Newspic;
    //新闻类型
    @Column(name = "newstype")
   	private  String Newstype;
    //发布时间
    @Column(name = "infodate")
	private  String Infodate;
    //内容
    @Column(name = "infocontent")
	private  String Infocontent;
    //发布人
    @Column(name = "memname")
	private  String Memname;
    public int getId() {
       return this.ID;
	   }
	public void setId(int ID) {
	   this.ID = ID;
       }
    public String getTitle() {
       return this.Title;
	   }
	public void setTitle(String Title) {
	   this.Title = Title;
	   }
    public String getSyschannel() {
       return this.Syschannel;
	   }
	public void setSyschannel(String Syschannel) {
	   this.Syschannel = Syschannel;
	   }
    public String getFname() {
       return this.Fname;
	   }
	public void setFname(String Fname) {
	   this.Fname = Fname;
	   }
    public String getCatename() {
       return this.Catename;
	   }
	public void setCatename(String Catename) {
	   this.Catename = Catename;
	   }
	 public String getNewstype() {
	       return this.Newstype;
		 }
    public void setNewstype(String Newstype) {
		   this.Newstype = Newstype;
		 }
     public String getNewspic() {
		   return this.Newspic;
	    }
	public void setNewspic(String Newspic) {
		this.Newspic = Newspic;
	    }
    public String getInfodate() {
       return this.Infodate;
	   }
	public void setInfodate(String Infodate) {
	   this.Infodate = Infodate;
	   }
    public String getInfocontent() {
       return this.Infocontent;
	   }
	public void setInfocontent(String Infocontent) {
	   this.Infocontent = Infocontent;
	   }
    public String getMemname() {
       return this.Memname;
	   }
	public void setMemname(String Memname) {
	   this.Memname = Memname;
	   }
    public String getYueri() throws ParseException {
    	SimpleDateFormat ny = new SimpleDateFormat("MM-dd");
    	Date d1 = new SimpleDateFormat("yyyy-MM-dd").parse(this.Infodate);
    	String shijian = ny.format(d1);
        return shijian;
 	   }
    public String getNianyue() throws ParseException {
    	SimpleDateFormat ny = new SimpleDateFormat("yyyy-MM");
    	Date d1 = new SimpleDateFormat("yyyy-MM-dd").parse(this.Infodate);
    	String shijian = ny.format(d1);
        return shijian;
 	   }
    public String getRi() throws ParseException {
    	SimpleDateFormat ri= new SimpleDateFormat("dd");
    	Date d1 = new SimpleDateFormat("yyyy-MM-dd").parse(this.Infodate);
    	String shijian = ri.format(d1);
        return shijian;
 	   }
    
    public String getContent(int count)
		{
			String ct="";
			String txtcontent = Infocontent.replaceAll("</?[^>]+>", "");   
		    txtcontent = txtcontent.replaceAll("<a>\\s*|\t|\r|\n</a>", "");
		    if(txtcontent.trim().length()>count){
		    ct=txtcontent.trim().substring(0,count);
		    }else
		    {
		    	ct=txtcontent.trim();
		    }
			return ct;	
		}
    public String getTitleByCount(int count) {
    	String ct="";	
    	
    	if(Title.trim().length()>count){
	    ct=this.Title.trim().substring(0,count);
    	}
	    else
	    {
	    	ct=this.Title.trim();	
	    }
		return ct;	
        
 	   }
}